﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class cn_down : System.Web.UI.Page
{
    protected string _cid = "";
    protected string mode = "";
    protected void Page_Load(object sender, EventArgs e)
    {

         Control ctr = null;
        mode = Request.QueryString["mode"];
        switch (mode)
        {
            case "baiy": ctr = this.LoadControl("common/menu_baiy.ascx"); break;
            case "about": ctr = this.LoadControl("common/menu_about.ascx"); break;
            case "ztactive": ctr = this.LoadControl("common/menu_ztactive.ascx"); break;
            case "jnews": ctr = this.LoadControl("common/menu_jnews.ascx"); break;
            case "pxnews": ctr = this.LoadControl("common/menu_pxnews.ascx"); break;
            case "kfu": ctr = this.LoadControl("common/menu_kfu.ascx"); break;
            case "kgarden": ctr = this.LoadControl("common/menu_kgarden.ascx"); break;
            case "index": ctr = this.LoadControl("common/menu_index.ascx"); break;

            default: ctr = this.LoadControl("common/menu_kfu.ascx"); break;
        }

        panne1.Controls.Add(ctr);


         _cid = Request.QueryString["cid"];
        if (string.IsNullOrEmpty(_cid))
        {
           // _cid = ColumnHelp.GetFirstColumnId(16);
        }
        else
        {
            if (!Whir.Common.WebHelper.Utils.IsInt(_cid))
                _cid = ColumnHelp.GetFirstColumnId(16);
        }
        if (!IsPostBack)
        {
            GetTipsInfo();
            GetList();
        }
    }

    private void GetTipsInfo()
    {
        if (!string.IsNullOrEmpty(_cid))
            ltrTips.Text = ColumnHelp.GetColumnName(_cid);
        else
            ltrTips.Text = "下载中心";
    }

    private void GetList()
    {
        string url = string.Format("about.aspx?cid={0}&mode=news", _cid);
        ColumnHelp.getReader(_cid, url, ColumnHelp.ModuleMarkMode.SinglePage);
        string where="1=1";
        AspNetPager1.PageSize = 12;
        if(!string.IsNullOrEmpty(_cid))
            where += " and TypeID=" + _cid;
        else
            where += " and TypeID in (18,22,34)";



        where += " and (IsTop='否' or IsTop is null)";
        string countSql = "SELECT COUNT(*) FROM Whir_U_News WHERE " + where;
        AspNetPager1.RecordCount = int.Parse(Whir.SQLServerDAL.DbHelperSQL.GetSingle(countSql).ToString());
        DataTable dt = Whir.SQLServerDAL.DbHelperSQL.GetList("Whir_U_News", "Whir_U_News_PID", "*", AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex - 1, where, "", "CreateDate desc").Tables[0];
        rptList.DataSource = dt;
        rptList.DataBind();


       

    }

    protected void AspNetPager1_PageChanged1(object sender, EventArgs e)
    {
        GetList();
    }
}
